<template>
  <el-radio-group v-model="value" v-bind="$attrs">
    <el-radio
      v-for="item in options"
      :value="item.value"
      v-bind="item.attrs"
      :key="item.value"
      >{{ item.label }}</el-radio
    >
  </el-radio-group>
</template>

<script setup lang="ts">
import { computed } from 'vue'

import { definePropType } from '@/utils'

export interface RadioOptions {
  label?: string
  value?: string | number
  attrs?: {}
}

const props = defineProps({
  options: {
    type: definePropType<RadioOptions[]>(Array),
    default: () => []
  },
  modelValue: [String, Number, Boolean]
})

const emits = defineEmits({
  'update:modelValue': (val: any) => val
})

const value = computed({
  get: () => {
    return props.modelValue
  },
  set: (val) => {
    emits('update:modelValue', val)
  }
})

defineOptions({
  name: 'CERadioGroup'
})
</script>

<style scoped></style>
